<?php
/**
 * 异常处理
 * 1.框架可以捕获 异常 notice
 * 致命错误 fatal ParseError 如果文件中语法错误，会导致访问文件就直接fatal
 */

namespace app\controllers;

use Yii;
use yii\filters\VerbFilter;
use yii\web\Controller;
use yii\web\Response;

class ErrorController extends Controller
{
    public function init()
    {
        parent::init();
        Yii::$app->response->format = Response::FORMAT_JSON;
    }

    public function actionException()
    {
        throw new \Exception('自定义异常');
    }

    public function actionNotice()
    {
       $b =  $a['iod'];
       return "hello world!";
    }

    public function actionFatal()
    {
        echo "abc"
    }

    public function actionUndefine()
    {
        undefinedFun();
    }
}